/**
 * 成本走势卡
 */
var timeDataMap = {
    'year': [1,2,3,4,5,6,7,8,9,10,11,12],
    'month': [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31],
    'day': [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23],
    'hour': [0,2,3,4,5,6,7,8,9,10,
        11,12,13,14,15,16,17,18,19,20,
        21,22,23,24,25,26,27,28,29,30,
        31,32,33,34,35,36,37,38,39,40,
        41,42,43,44,45,46,47,48,49,50,
        51,52,53,54,55,56,57,58,59]
};
var timeFormatMap = {
    'year': "%Y-%m",
    'month': "%Y-%m-%d",
    'day': "%Y-%m-%d %H",
    'hour': "%Y-%m-%d %H:%m"
};
var timeSingleFormatMap = {
    'year': "%m",
    'month': "%d",
    'day': "%H",
    'hour': "%m"
};

dev.action = function(resp,param){
    var theTime = param.time;
    var workSpace = param.workSpace;
    var db = iot.db();
    var format,singleFormate;
    var electricityResult = null;
    var gasResult = null;
    // 2019之后的数据
    var carbonEq2019Result = null;

    var timeSub = parseInt(theTime.substring(0,4));

    var resultData = {
        xData : iot.list(),
        yLeft: iot.list(),
        yRight : iot.list()
    };

    var timeType = iot.getTimeByFormat(theTime);
    var timeDataList = timeDataMap[timeType];
    format = timeFormatMap[timeType];
    singleFormate = timeSingleFormatMap[timeType];

    var dm = iot.getNumberFormat("00");

    for(var ix in timeDataList){
        var timeItem = dm.format(timeDataList[ix]);
        var data  = parseInt(Math.random()*3434343559);
        resultData.xData.add(timeItem);
        resultData.yLeft.add(data);
    }

    for(var ix in timeDataList){
        var timeItem = dm.format(timeDataList[ix]);
        var data  = parseInt(Math.random()*25678);
        resultData.yRight.add(data);
    }
    resp.setJsData(resultData);
}
